<template>
  <el-link v-if="!tag" :type="type" class="wx-link" :class="{'lk-tx-flow':textOverflow}" target="_blank"
           :underline="false">
    <slot/>
  </el-link>
  <el-tag v-else :type="type" class="wx-link" :class="{'lk-tx-flow':textOverflow}" :closable="closable"
          @close="tagClose">
    <slot/>
  </el-tag>
</template>

<script>
/**
 * type:danger warning success primary
 * @close 关闭事件
 */
export default {
  name: "wxLink",
  props: {
    type: {
      type: String,
      default: 'primary'
    },
    tag: {
      type: Boolean,
      default: false
    },
    textOverflow: {
      type: Boolean,
      default: false
    },
    closable: false
  },
  data() {
    return {}
  },
  methods: {
    tagClose(e) {
      this.$emit('close')
    }
  }
}
</script>

<style scoped lang="scss">
.wx-link {
  margin: 2px 4px;
}

.lk-tx-flow {
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  width: 100%;
}
</style>
